home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2447 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  957 b 

  1. Path: castle.nando.net!news
  2. From: actuary@nando.net   (Bill McCarthy)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: cpp question
  5. Date: 21 Jan 1996 16:41:49 GMT
  6. Organization: News & Observer Public Access
  7. Message-ID: <4dtqcd$8r5@castle.nando.net>
  8. References: <4drm99$j0m@peabody.colorado.edu>
  9. Reply-To: actuary@nando.net (Bill McCarthy)
  10. NNTP-Posting-Host: vyger315.nando.net
  11. X-Newsreader: IBM NewsReader/2 v1.2
  12.  
  13. In <4drm99$j0m@peabody.colorado.edu>,
  14. woodjr@rintintin.Colorado.EDU (WOOD  JAMEY RYAN) writes:
  15.  
  16. >I have something like this:
  17. >
  18. >     #define USERLEN 8
  19. >     #define HOSTLEN 15
  20. >
  21. >     char name[] = "woodjr";
  22. >     char host[] = "really.long.hostname.com";
  23. >     char s[100];
  24. >
  25. >     sprintf(s, "%.USERLENs@%.HOSTLENs", name, host);
  26. >
  27. >And I want cpp to parse the sprintf line to:
  28. >
  29. >     sprintf(s, "%.8s@%.15s", name, host);
  30.  
  31. Try it like this:
  32.  
  33.    sprintf(s, "%.*s@%.*s", USERLEN, name, HOSTLEN, host);
  34.  
  35. Bill McCarthy
  36. actuary@nando.net
  37. Wendell, NC  USA
  38.  
  39.